#ifndef UNIXNetworkManager_H
#define UNIXNetworkManager_H
#include "inetworkmanager.h"
#ifdef OS_UNIX
#include <sys/select.h>
#include <list>
#include <string.h>
#include "player.h"

class UNIXNetworkManager : public INetworkManager
{
 public:
  UNIXNetworkManager();
  virtual void addPlayer(Player *);
  virtual void removePlayer(Player *);
  virtual void run(long uTimeout = -1);
  virtual void runGame(long uTimeout = -1);

 private:
  void generateReadFs();
  void generateWriteFs();
  
 private:
  fd_set  _readfs;
  fd_set  _writefs;
  fd_set  _readfscpy;
  int     _maxfd;
  bool    _hasWriteFs;
  char    *_mainBuffer;
  std::list<Player *> _players;
};

#endif
#endif // UNIXNetworkManager_H
